import {createApp} from 'vue'
import App from './App.vue'
import router, {setupRouter} from '@/router'
import {setupStore} from '@/store'

import dayjs from 'dayjs'
import vuetify from './plugins/vuetify'
import ElementPlus from 'element-plus'
import TyModal from '@/components/ty-modal/Index.vue'
import locale from 'element-plus/lib/locale/lang/zh-cn'
import 'dayjs/locale/zh-cn'
import 'animate.css';
import 'element-plus/lib/theme-chalk/index.css'
import './static/css/common.css'

import './static/js/common.js'
import "./libs/smoothscroll-polyfill";

import VueQrcode from '@chenfengyuan/vue-qrcode';
import {VueClipboard} from '@soerenmartius/vue3-clipboard'

import { websocketClient } from "./libs";
websocketClient.connect();

const components = [TyModal]

async function bootstrap() {
    const app = createApp(App)

    app.use(ElementPlus, {locale})

    components.forEach(component => {
        app.component(component.name, component)
    })

    app.config.globalProperties.$dayjs = dayjs
    app.config.globalProperties.BASE_URL = import.meta.env.VITE_BASE_URL

    // @ts-ignore
    app.component(VueQrcode.name, VueQrcode)

    app.use(vuetify)
    app.use(VueClipboard)

    setupStore(app)

    setupRouter(app)

    await router.isReady()

    app.mount('#app')
}

void bootstrap();
